using System;
using System.Text;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Drawing;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class ResponsePropertyPage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        CreateImage();
        //CreateText();

    }
    void CreateText()
    {
        Response.ContentType = "text/html";
        Response.Charset = "utf-8";
        Response.AddHeader("meta","khang");
        
        Label label = new Label();
        label.Text = "Học lập trình ASP.NET 2.0 dễ quá";
        this.form1.Controls.Add(label);
        Response.Flush();
    }
    void CreateImage()
    {
        Response.ContentType = "image/jpeg";
        Response.Clear();

        Response.BufferOutput = true;

        Font rectangleFont = new Font(
            "Arial", 11, FontStyle.Bold);

        int height = 100;
        int width = 200;

        Random r = new Random();
        int x = r.Next(70);
        int a = r.Next(150);
        int x1 = r.Next(110);

        Bitmap bmp = new Bitmap(
        width, height, 
        PixelFormat.Format24bppRgb);
        Graphics graphics = 
        Graphics.FromImage(bmp);

        graphics.SmoothingMode = 
        SmoothingMode.AntiAlias;
        graphics.Clear(Color.LightGray);


        graphics.DrawRectangle(Pens.White, 1, 1, 
        width - 3, height - 3);
        graphics.DrawRectangle(Pens.Aquamarine, 2, 
        2, width - 3, height - 3);
        graphics.DrawRectangle(Pens.Black, 0, 0, 
        width, height);


        graphics.DrawString(
            "ASP.NET 2.0", rectangleFont,
            SystemBrushes.WindowText, 
            new PointF(10, 40));


        graphics.FillRectangle(
            new SolidBrush(
                Color.FromArgb(a, 255, 128, 255)),
            x, 20, 100, 50);

        graphics.FillRectangle(
            new LinearGradientBrush(
                new Point(x, 10),
                new Point(x1 + 75, 50 + 30),
                Color.FromArgb(128, 0, 0, 128),
                Color.FromArgb(255, 255, 255, 240)),
            x1, 50, 75, 30);


        bmp.Save(Response.OutputStream, 
        ImageFormat.Jpeg);

        graphics.Dispose();
        bmp.Dispose();

        Response.Flush();
    }
}
